package org.geemp.game.gm.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author JackRen
 * @date 2021-12-01 14:43
 * @description:
 */
public interface GameMapper {

    @Select("select CT_INGOT,CT_GOLD,CT_POINT from chartable where CT_USERID = #{CT_USERID} and CT_NAME=#{CT_NAME}")
    List<Map<String,Object>> obtainDataBy(@Param("CT_USERID") String CT_USERID,@Param("CT_NAME") String CT_NAME);

    @Select("select CT_SEQ from chartable where CT_USERID = #{CT_USERID} and CT_NAME=#{CT_NAME}")
    Map<String,Object> obtainChartIndexBy(@Param("CT_USERID") String CT_USERID,@Param("CT_NAME") String CT_NAME);

    @Select("select IT_ITEMIDX,IT_SEQ,IT_OPTIONID1,IT_OPTIONVALUE1,IT_OPTIONID2,IT_OPTIONVALUE2,IT_OPTIONID3,IT_OPTIONVALUE3,IT_OPTIONID4,IT_OPTIONVALUE4,IT_OPTIONID5,IT_OPTIONVALUE5,IT_OPTIONID6,IT_OPTIONVALUE6,IT_OPTIONID7,IT_OPTIONVALUE7 from INVENTORYTABLE where IT_WHERE=1 AND IT_USERIDX = #{IT_USERIDX} and IT_SLOTTYPE=#{IT_SLOTTYPE}")
    Map<String,Object> obtainITEMIDXBy(@Param("IT_USERIDX") String IT_USERIDX,@Param("IT_SLOTTYPE") String IT_SLOTTYPE);

    @Update({
            "<script> ",
            "update inventorytable set ",
            "<if test = \"IT_OPTIONID1 != null\"> ",
            "IT_OPTIONID1=#{IT_OPTIONID1}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE1 != null\"> ",
            "IT_OPTIONVALUE1=#{IT_OPTIONVALUE1}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID2 != null\"> ",
            "IT_OPTIONID2=#{IT_OPTIONID2}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE2 != null\"> ",
            "IT_OPTIONVALUE2=#{IT_OPTIONVALUE2}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID3 != null\"> ",
            "IT_OPTIONID3=#{IT_OPTIONID3}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE3 != null\"> ",
            "IT_OPTIONVALUE3=#{IT_OPTIONVALUE3}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID4 != null\"> ",
            "IT_OPTIONID4=#{IT_OPTIONID4}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE4 != null\"> ",
            "IT_OPTIONVALUE4=#{IT_OPTIONVALUE4}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID5 != null\"> ",
            "IT_OPTIONID5=#{IT_OPTIONID5}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE5 != null\"> ",
            "IT_OPTIONVALUE5=#{IT_OPTIONVALUE5}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID6 != null\"> ",
            "IT_OPTIONID6=#{IT_OPTIONID6}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE6 != null\"> ",
            "IT_OPTIONVALUE6=#{IT_OPTIONVALUE6}, ",
            "</if> ",
            "<if test = \"IT_OPTIONID7 != null\"> ",
            "IT_OPTIONID7=#{IT_OPTIONID7}, ",
            "</if> ",
            "<if test = \"IT_OPTIONVALUE7 != null\"> ",
            "IT_OPTIONVALUE7=#{IT_OPTIONVALUE7} ",
            "</if> ",
            "WHERE IT_SEQ=#{IT_SEQ}",
            "</script>"
    })
    int updateItemInfoByID(@Param("IT_SEQ") int IT_SEQ,@Param("IT_OPTIONID1") int IT_OPTIONID1,@Param("IT_OPTIONVALUE1") int IT_OPTIONVALUE1,
                           @Param("IT_OPTIONID2") int IT_OPTIONID2,@Param("IT_OPTIONVALUE2") int IT_OPTIONVALUE2,
                           @Param("IT_OPTIONID3") int IT_OPTIONID3,@Param("IT_OPTIONVALUE3") int IT_OPTIONVALUE3,
                           @Param("IT_OPTIONID4") int IT_OPTIONID4,@Param("IT_OPTIONVALUE4") int IT_OPTIONVALUE4,
                           @Param("IT_OPTIONID5") int IT_OPTIONID5,@Param("IT_OPTIONVALUE5") int IT_OPTIONVALUE5,
                           @Param("IT_OPTIONID6") int IT_OPTIONID6,@Param("IT_OPTIONVALUE6") int IT_OPTIONVALUE6,
                           @Param("IT_OPTIONID7") int IT_OPTIONID7,@Param("IT_OPTIONVALUE7") int IT_OPTIONVALUE7);

    @Select("select WUC_NAME,WUC_OPTIONVALUE,WUC_FREEVALUE from WEBUPGRADECHART")
    List<Map<String,Object>> obtainUpGradeCharInfo();

    @Select("select WUC_NAME,WUC_OPTIONVALUE,WUC_FREEVALUE from WEBUPGRADECHART1")
    List<Map<String,Object>> obtainUpGradeChar1Info();

    @Select("select IT_USERIDX from INVENTORYTABLE where IT_SEQ=#{IT_SEQ}")
    int obtainInventoryIndex(@Param("IT_SEQ") int IT_SEQ);

    @Select("select CT_GOLD,CT_SEQ from chartable where CT_CHARINDEX=#{CT_CHARINDEX} and CT_USERID=#{CT_USERID}")
    Map<String,Object> obtainCharGoldIndex(@Param("CT_CHARINDEX") int CT_CHARINDEX,@Param("CT_USERID") String CT_USERID);

    @Update("update chartable set CT_GOLD=#{CT_GOLD} where CT_SEQ=#{CT_SEQ}")
    int updateCTChartInfo(@Param("CT_GOLD") int CT_GOLD,@Param("CT_SEQ") int CT_SEQ);

}
